import baidu_client
from utils import rec_audio


def listen(filename):
    with open(filename, 'rb') as f:
        audio_data = f.read()
        result = client.asr(audio_data, 'wav', 16000, {
            'dev_pid': 1536,
        })
        if result["err_no"] == 0:
            result_text = result["result"][0]
            return result_text


client = baidu_client.speech;

rec_audio.rec("recording.wav", 5)
said = listen('recording.wav')
print("you said: " + said)
